package com.yds.dccjll.androidhome.base;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.yds.dccjll.androidhome.R;
import com.yds.dccjll.androidhome.base.util.AppUtil;

import java.util.List;

public abstract class BaseActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题
//        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉状态栏
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (getBackClickListener() != null) {
            findViewById(R.id.backIv).setOnClickListener(getBackClickListener());
        } else {
            findViewById(R.id.backIv).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
        }
        findViewById(R.id.backIv).setVisibility(showBack() ? View.VISIBLE : View.GONE);
        ((TextView)findViewById(R.id.titleTv)).setText(getTitleInfo());
        AppUtil.initAdapter(this, initItemList());
    }

    public abstract boolean showBack();

    public abstract View.OnClickListener getBackClickListener();

    public abstract String getTitleInfo();

    public abstract List<Object> initItemList();
}
